<?php
/*define autoload*/
define('PATH_SYSTEM', 'system/');
$PATH_APPLICATION = NULL;

function __autoload( $class_name )
{
     global $PATH_APPLICATION;
     
     $class_name = trim($class_name);
	 $arr_name = explode("__",$class_name);
	 $folder = empty($arr_name[0])?NULL:str_replace( '_', '\\', $arr_name[0]);
	 $file = empty($arr_name[1])?NULL:$arr_name[1];
	 
	 if(empty($arr_name[1])){
		
		$file_path = $folder;
		
	 } else {
		
		$file_path = empty($folder)?$file:$folder.'\\'.$file;
	 }
	 	 
	 if(file_exists(PATH_LIB.$file_path.'.php'))
	 {
		require(PATH_LIB.$file_path.'.php');
		return;
	 }

     if(file_exists($PATH_APPLICATION.$file_path.'.php'))
	 {
		require($PATH_APPLICATION.$file_path.'.php');
		return;
	 }
     
     if(file_exists(PATH_SYSTEM.$file_path.'.php'))
	 {
		require(PATH_SYSTEM.$file_path.'.php');
		return;
	 }else{
		echo 'Not Class '.$class_name; exit;
	 }
}
